In general, the use of javascript inside HTML code is not good practice. As an alternative, Sitecore V5 provides you with special field type for use with Javascript links. This is called the Link field. The following steps describe how to use this field type:
In this case javascript link will be inserted into page with onClick attribute. Please have a look at the example result:
<p><a title="text" href="#" onclick="javascript:window.open();return false;">link</a></p>
At the moment, due to a known issue, the HTML editor does not save the onClick attribute included in an <a> tag. You are able to put javascript code into href attribute, but it is sometimes necessary to put javascript code into the onClick attribute of an <a> tag.
In these cases, you can use the Publish Replacements facility to put javascript code into onClick attribute.
For this you should enable a Replacer in the web.config and add a replecement that will read javascript code from the href attribute and replace it with an onClick attribute.
<replacers>
<replacer mode="on" id="publish" type="Sitecore.Text.Replacer, Sitecore.Kernel" singleInstance="true">
<param desc="name">$(id)</param>
<replacements hint="raw:AddReplacement">
<regex find="<a href="javascript:(.*)">(.*)</a>"
replaceWith="<a href="javascript:;" onClick="$1">$2</a>"
ignoreCase="true" />
</replacements>
</replacer>
</replacers>
Once you have configured this replacer, Sitecore will replace the link:
<a href="javascript:window.open()">Open Window</a>
to
<a href="javascript:void(0);" onClick="window.open()">Open Window</a>